home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c++
- Subject: Re: ODBC SQL problems
- Date: Thu, 21 Mar 1996 12:17:44 +0200
- Organization: Carelcomp Products
- Message-ID: <31512CC8.7A04@cmt.lpr.mail.carel.fi>
- References: <4ipiil$3j8@news.cais.com>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Matthew Baird wrote:
- >
- > I've written an application that allows the user to pass SQL queries to an
- > ODBC datasource, then dynamically binds the columns and displays the results
- > in a template. I have two problems currently:
- >
- > How do I truncate the data in a SQL_TIMESTAMP field so that when I
- > display it, the field shows only the date portion? Here is a snippet of code:
- >
- > case SQL_TIMESTAMP:
- > data[i] = new UCHAR[24];
- > rc = SQLBindCol(hstmt, i+1, SQL_C_CHAR, data[i], 24, &outlen[i]);
- > break;
- >
- > Interestingly it doesn't matter how much space I allocate in my new UCHAR
- > line, but if I change the 24 in the SQLBindCol, I get strange errors.
- >
-
- One way: just fetch the data and when displaying it, then do the truncation. Another
- way: use SQL_C_DATE and have the ODBC driver make the conversion from timestamp to a
- date (remember, in this case, the date is returned in a structure).
-
- >
- > My second question is if a user enters a query that is made of two
- > distinct queries ie.
- >
- > Delete from table where user='smith' Select * from table
- >
- > how do I fetch only the results from the valid SELECT statement?
- >
-
- I don't quite get what you mean, but maybe you'd want to separate this example into
- two different parts (delete ... and select ...) and then do what you normally do
- when selecting (bind columns, fetch etc).
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-